﻿@using PNProject
@using PNProject.EF;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout1.cshtml";
    int active = Convert.ToInt16(ViewData["page-active"]);
    int total = (int)(ViewData["page-total"]);
    int pc = (int)(ViewData["page-pc"]);List<int> listPage = (List<int>)(ViewData["page-list"]);
    List<Feedback> feeds = (List<Feedback>)(ViewData["news"]);
    int last = 1;
    if (listPage.Count > 1)
    {
        last = listPage.ElementAt(listPage.Count - 1);
    }
    bool lang = (bool)(ViewData["lang"]);
    string langText = lang ? "" : "en-US/";
}
<div class="hoidap">
@foreach (var item in feeds)
{
    <div class="boxhoidap">
        <ul>
            <li class="hoi-I"><a href="/@string.Concat(langText,"qa/detail/", item.FeedbackID.ToString())">@item.Title</a></li>
            <li class="hoi-II">
                <p>@item.Message</p>
                <a href="/@string.Concat(langText,"qa/detail/", item.FeedbackID.ToString())">Xem tiếp...</a>
            </li>
        </ul>
    </div>
}


<div class="pageT">
    <ul>
        <li><a href="/@string.Concat(langText,"qa/index?p=1")">Trang đầu</a></li>
        @foreach (var item in listPage)
        {
            if (item == active)
            {
                    <li class="active"><a href="/@string.Concat(langText, "qa/index?p=", item.ToString())">@item.ToString()</a></li>
            }
            else
            {
                <li><a href="/@string.Concat(langText, "qa/index?p=", item.ToString())">@item.ToString()</a></li>
            }
        }
        @if (last < pc)
        {
        <li><a href="/@string.Concat(langText, "qa/index?p=", (last+1).ToString())">...</a></li>
        <li><a href="#"><img src="/images/icon-14.png" alt="" /></a></li>
        }
        <li><a href="/@string.Concat(langText, "qa/index?p=", pc.ToString())">Trang cuối</a></li>
    </ul>
</div>

</div>

    <script type="text/javascript">
        $(document).ready(function () {
            $(".titlesub p").empty();
            var lang = document.URL.indexOf("en-US") < 0 ? true : false;
            if (lang) {
                $(".titlesub p").append("Hỏi đáp");
                $("#ulink_home a").append("Trang chủ");
                $("#ulink_child a").append("Hỏi đáp");
                $("#ulink_child a").attr("href", "/qa");
            }
            else {
                $(".titlesub p").append("Question - Answer");
                $("#ulink_home a").append("Home");
                $("#ulink_home a").attr("href", "/en-US/home");
                $("#ulink_child a").append("Question - Answer");
                $("#ulink_child a").attr("href", "/en-US/qa");
            }
        });
</script>